//
//  CZVistorTableViewController.swift
//  WHWeiBo
//
//  Created by Li Changjian on 16/7/9.
//  Copyright © 2016年 Li Changjian. All rights reserved.
//

import UIKit

class CZVistorTableViewController: UITableViewController {
/// 登录状态
    var isLogin: Bool = CZUserAccountViewModel.sharedUserAccount.isLogin
    
    var vistorView: CZVistorView?
    
    // MARK: - 重写loadView方法,根据用户登录状态设置view显示样式
    override func loadView() {
        if isLogin {
            super.loadView()
        }else {
            vistorView = CZVistorView()
            view = vistorView
            
            vistorView?.loginClosure = { [weak self] in
                self?.loginAction()
            }
            
            setUpNavi()
            
        }
    }
    
    // MARK: - 设置导航栏
    func setUpNavi() {
        
        navigationItem.leftBarButtonItem = UIBarButtonItem.init(title: "注册", target: self, action: "registerAction")
        navigationItem.rightBarButtonItem = UIBarButtonItem.init(title: "登录", target: self, action: "loginAction")
    }
    // MARK: - 注册
    func registerAction() {
        loginAction()
    }
    // MARK: - 登录
    func loginAction() {
        let czOAthVC = CZOAuthViewController()
        let navi = UINavigationController(rootViewController: czOAthVC)
        presentViewController(navi, animated: true, completion: nil)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        
    }

   

}
